//
//  LXMyCommissionViewController.m
//  LvXi_newVersion
//
//  Created by 诸葛孔明 on 16/9/6.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "LXMyCommissionViewController.h"
#import "LXMyCommissionHeaderView.h"

#import "BillColtroller.h"
#import "LXMallShareController.h"

#import "LXNoHighLightViewCell.h"

#import "LXCommissionTeamController.h"
static NSString *const cellID = @"LXNoHighLightViewCell";

@interface LXMyCommissionViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,weak) UITableView *tableView;

@end

@implementation LXMyCommissionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpTableView];
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self setUpNavi];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

-(void)setUpNavi{
    [super setUpNavi];
}

- (void)setUpTableView
{
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.contentInset = (UIEdgeInsets){-20,0,0,0};
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    LXMyCommissionHeaderView *commissionHeaderView = [[LXMyCommissionHeaderView alloc] init];
    commissionHeaderView.frame = CGRectMake(0, 0, ScreenHeight, MineRatio(224));
    tableView.tableHeaderView = commissionHeaderView;
    
    [self.view addSubview:tableView];
    self.tableView = tableView;
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        LXNoHighLightViewCell *orderCell = [[LXNoHighLightViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        orderCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        orderCell.imageView.image = [UIImage imageNamed:@"bill"];
        orderCell.textLabel.text = @"我的账单";
        orderCell.textLabel.font = [UIFont systemFontOfSize:15];
        orderCell.textLabel.textColor = HexColor(@"#222222");
        [orderCell setBackgroundImageViewHeight:50];
        orderCell.roundStyle = RoundStyleTop;
        orderCell.enableUnaderLine = YES;
        return orderCell;
    }else if (indexPath.row == 1){
        LXNoHighLightViewCell *teamCell = [[LXNoHighLightViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        teamCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        teamCell.imageView.image = [UIImage imageNamed:@"team"];
        teamCell.textLabel.text = @"我的团队";
        teamCell.textLabel.font = [UIFont systemFontOfSize:15];
        teamCell.textLabel.textColor = HexColor(@"#222222");
        [teamCell setBackgroundImageViewHeight:50];
        teamCell.roundStyle = RoundStyleNone;
        teamCell.enableUnaderLine = YES;
        return teamCell;
    }
    
    LXNoHighLightViewCell *moneyCell = [[LXNoHighLightViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    moneyCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    moneyCell.imageView.image = [UIImage imageNamed:@"To-make-money"];
    moneyCell.textLabel.text = @"推广赚钱";
    moneyCell.textLabel.font = [UIFont systemFontOfSize:15];
    moneyCell.textLabel.textColor = HexColor(@"#222222");
    [moneyCell setBackgroundImageViewHeight:50];
    moneyCell.roundStyle = RoundStyleBottom;
    moneyCell.enableUnaderLine = NO;
    return moneyCell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        BillColtroller *billVc = [[BillColtroller alloc] init];
        [self.navigationController pushViewController:billVc animated:YES];

    }else if (indexPath.row == 2){
        LXMallShareController *shareVc = [[LXMallShareController alloc] init];
        [self.navigationController pushViewController:shareVc animated:YES];

    }else{
        LXCommissionTeamController *groupVc = [[LXCommissionTeamController alloc] init];
        [self.navigationController pushViewController:groupVc animated:YES];

    }
}

@end
